home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / MacMETH 3.2.1 / MacMETH Manual 1992 / Manual Examples / DialogExample.MOD < prev    next >
Encoding:
Text File  |  1992-10-09  |  1.5 KB  |  45 lines  |  [TEXT/MEDT]

  1. MODULE DialogExample; (* demonstrates dialog handling *)
  2.  
  3.       FROM Dialog IMPORT    Dialog, Item, New, Dispose, Close, UserAction, Button,
  4.                              Boolean, Enumeration, String, StaticString, TextStyle,
  5.                              windowItem;
  6.                      
  7.       TYPE    RadioType = (Button1,Button2);
  8.       VAR      dialog                   : Dialog;
  9.            Quit, Cancel, Check,
  10.            Radio, Text, TheItem    :    Item;
  11.            RadioValue    :    RadioType;
  12.            CheckValue    :    BOOLEAN;
  13.            TextValue    :    ARRAY [0..63] OF CHAR;
  14.        
  15.       PROCEDURE Beep(Duration : INTEGER); CODE 0A9C8H;
  16.     (* Code procedure, see chapter 8! *)
  17. BEGIN
  18.       (* Create dialog *)
  19.       New(dialog, 50,50,400,200);
  20.       (* Define dialog items *)
  21.       Button(dialog,Quit,TRUE,90,10,"Quit");
  22.       Button(dialog,Cancel,FALSE,250,10,"Cancel");
  23.       Boolean(dialog,Check,CheckValue,10,100,"Check Box");
  24.       RadioValue := Button2;
  25.       Enumeration(dialog,Radio,RadioValue,200,100,0,20,"Radio Button 1|Radio Button 2");
  26.       TextValue := "This is an example.";
  27.       String(dialog,Text,TextValue,10,50,364);
  28.       StaticString(dialog,"Sample Dialog",150,150,Underline);
  29.       (* Dialog defined; display it and monitor user's actions *)
  30.       REPEAT
  31.         LOOP
  32.               IF UserAction(dialog,TheItem) THEN
  33.                 IF (TheItem = Quit) OR (TheItem = Cancel) THEN
  34.                       EXIT
  35.                 ELSIF (TheItem = windowItem) THEN
  36.                       Beep(5)
  37.                 END (* IF *)
  38.               END (* IF *)
  39.         END (* LOOP *);
  40.         Close(dialog)
  41.       UNTIL (TheItem = Quit);
  42.       Dispose(dialog)
  43. END DialogExample.
  44.  
  45.